package edu.gatech.startrader.gui;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import javax.swing.JDialog;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextPane;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.JTable;
import javax.swing.UIManager;

import javax.swing.JInternalFrame;
import javax.swing.SwingConstants;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.table.DefaultTableModel;

import javax.swing.border.MatteBorder;

import edu.gatech.startrader.Game;
import edu.gatech.startrader.player.Player;
import edu.gatech.startrader.ship.Ship;
import edu.gatech.startrader.trade.TradeGood;
import edu.gatech.startrader.universe.Planet;
import edu.gatech.startrader.universe.Universe;

import java.awt.Color;
import java.awt.Panel;
import javax.swing.ImageIcon;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Frame;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JScrollPane;
import java.awt.Rectangle;

public class ShipYardScreen extends JDialog
{
	private JTable table;
	private Ship ship;
	private Planet planet;


	/**
	 * showWarpScreen method
	 * This method shows the warp screen
	 * @param owner the frame
	 * @param play the player
	 * @param uni the current universe
	 */
	public static void showShipYardScreen(Frame owner, Ship playerShip, Planet currentPlanet){
		ShipYardScreen dialog = new ShipYardScreen(owner, true, playerShip, currentPlanet);
		dialog.setVisible(true);
		owner.repaint();
		return;
	}
	/**
	 * WarpScreen constructor
	 * Create the dialog.
	 * @param owner the frame
	 * @param modal boolean value
	 * @param play the player
	 * @param uni the current universe
	 */	
	//	public WarpScreen(Frame owner, boolean modal, Player play, final Universe uni) 
	public ShipYardScreen(Frame owner, boolean modal, Ship playerShip, Planet currentPlanet) 
	{
		super(owner, modal);
		setBounds(new Rectangle(100, 100, 680, 350));
        try {
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e) {
        }		
		setTitle("Ship Yard\r\n");
		getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.CENTER);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{38, 58, 18, 58, 58, 53, 46, 187, 44, 0};
		gbl_panel.rowHeights = new int[]{192, 23, 23, 0, 0, 0};
		gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		JScrollPane scrollPane = new JScrollPane();
		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
		gbc_scrollPane.gridwidth = 9;
		gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
		gbc_scrollPane.fill = GridBagConstraints.BOTH;
		gbc_scrollPane.gridx = 0;
		gbc_scrollPane.gridy = 0;
		panel.add(scrollPane, gbc_scrollPane);
		
		table = new JTable();
		scrollPane.setViewportView(table);
		table.setEnabled(false);
		table.setSurrendersFocusOnKeystroke(true);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{"", null, "", null, null, null, null, null},
				{"", null, "", null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, "", null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
			},
			new String[] {
				"Ship", "Price", "Hull", "Range", "Crew Size", "Weapon Slots", "Shield Slots", "Gadget Slots"
			}
		) {
			Class[] columnTypes = new Class[] {
				String.class, Object.class, Object.class, Object.class, Object.class, Object.class, Object.class, Object.class
			};
			public Class getColumnClass(int columnIndex) {
				return columnTypes[columnIndex];
			}
			boolean[] columnEditables = new boolean[] {
					false, false, false, false, false, false, false, false, false, false
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		table.getColumnModel().getColumn(0).setPreferredWidth(49);
		table.getColumnModel().getColumn(1).setPreferredWidth(50);
		table.getColumnModel().getColumn(2).setPreferredWidth(42);
		table.getColumnModel().getColumn(3).setPreferredWidth(42);
		table.getColumnModel().getColumn(4).setPreferredWidth(58);
		table.getColumnModel().getColumn(5).setPreferredWidth(85);
		table.getColumnModel().getColumn(6).setPreferredWidth(74);
		
		JButton btnNewButton = new JButton("Refuel");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.anchor = GridBagConstraints.NORTH;
		gbc_btnNewButton.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
		gbc_btnNewButton.gridwidth = 2;
		gbc_btnNewButton.gridx = 0;
		gbc_btnNewButton.gridy = 1;
		panel.add(btnNewButton, gbc_btnNewButton);
		
		JButton btnBuyWeapons = new JButton("Buy Weapons");
		GridBagConstraints gbc_btnBuyWeapons = new GridBagConstraints();
		gbc_btnBuyWeapons.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnBuyWeapons.anchor = GridBagConstraints.NORTH;
		gbc_btnBuyWeapons.insets = new Insets(0, 0, 5, 5);
		gbc_btnBuyWeapons.gridwidth = 2;
		gbc_btnBuyWeapons.gridx = 3;
		gbc_btnBuyWeapons.gridy = 1;
		panel.add(btnBuyWeapons, gbc_btnBuyWeapons);
		
		JButton btnRepair = new JButton("Repair");
		GridBagConstraints gbc_btnRepair = new GridBagConstraints();
		gbc_btnRepair.anchor = GridBagConstraints.NORTH;
		gbc_btnRepair.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnRepair.insets = new Insets(0, 0, 5, 5);
		gbc_btnRepair.gridwidth = 2;
		gbc_btnRepair.gridx = 0;
		gbc_btnRepair.gridy = 2;
		panel.add(btnRepair, gbc_btnRepair);
		
		JButton btnNewButton_1 = new JButton("Buy Shields");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
		gbc_btnNewButton_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnNewButton_1.anchor = GridBagConstraints.NORTH;
		gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 5);
		gbc_btnNewButton_1.gridwidth = 2;
		gbc_btnNewButton_1.gridx = 3;
		gbc_btnNewButton_1.gridy = 2;
		panel.add(btnNewButton_1, gbc_btnNewButton_1);
		
		JButton btnNewButton_3 = new JButton("Hire Mercenaries");
		GridBagConstraints gbc_btnNewButton_3 = new GridBagConstraints();
		gbc_btnNewButton_3.anchor = GridBagConstraints.NORTH;
		gbc_btnNewButton_3.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnNewButton_3.insets = new Insets(0, 0, 5, 5);
		gbc_btnNewButton_3.gridwidth = 2;
		gbc_btnNewButton_3.gridx = 0;
		gbc_btnNewButton_3.gridy = 3;
		panel.add(btnNewButton_3, gbc_btnNewButton_3);
		
		JButton btnNewButton_2 = new JButton("Buy Gadgets");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		GridBagConstraints gbc_btnNewButton_2 = new GridBagConstraints();
		gbc_btnNewButton_2.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnNewButton_2.anchor = GridBagConstraints.NORTH;
		gbc_btnNewButton_2.insets = new Insets(0, 0, 5, 5);
		gbc_btnNewButton_2.gridwidth = 2;
		gbc_btnNewButton_2.gridx = 3;
		gbc_btnNewButton_2.gridy = 3;
		panel.add(btnNewButton_2, gbc_btnNewButton_2);
		
		JButton btnBack = new JButton("Back");
		btnBack.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		GridBagConstraints gbc_btnBack = new GridBagConstraints();
		gbc_btnBack.insets = new Insets(0, 0, 5, 0);
		gbc_btnBack.anchor = GridBagConstraints.NORTH;
		gbc_btnBack.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnBack.gridx = 8;
		gbc_btnBack.gridy = 3;
		panel.add(btnBack, gbc_btnBack);
	}
	
	public void repaint()
	{
		
	}
}
